import prompt from "@system.prompt";
import router from "@system.router";

export default {
    tabChange(e) {
        console.info("Tab index: " + e.index);
    },

    data: {
        title: "World",
        // 顶部栏
        username: "阿伟",
        num: 4,
        // 底部菜单栏
        menuData: [
            {
                imgSrc: "common/images_bottom_menu_bar/home.png",
                imgSrcActive: "common/images_bottom_menu_bar/home_active.png",
                title: "首页",
            },
            {
                imgSrc: "common/images_bottom_menu_bar/scenarios.png",
                imgSrcActive:
                    "common/images_bottom_menu_bar/scenarios_active.png",
                title: "场景",
            },
            {
                imgSrc: "common/images_bottom_menu_bar/message.png",
                imgSrcActive:
                    "common/images_bottom_menu_bar/message_active.png",
                title: "消息",
            },
            {
                imgSrc: "common/images_bottom_menu_bar/mine.png",
                imgSrcActive: "common/images_bottom_menu_bar/mine_active.png",
                title: "我的",
            },
        ],
        defaultIndex: 1,
        content: [
            {
                imgSrc: "common/home/u327.png",
                position: "室外",
                num: 4,
                temperature: 30,
                humidity: 49,
                luminance: 50,
            },
            {
                imgSrc: "common/home/u339.png",
                position: "主卧",
                num: 4,
                temperature: 30,
                humidity: 49,
                luminance: 50,
            },
            {
                imgSrc: "common/home/u310.png",
                position: "室外",
                num: 4,
                temperature: 30,
                humidity: 49,
                luminance: 50,
            },
        ],
    },
    bottomNavigationBarClick(num) {
        this.defaultIndex = num;
        if (0 == this.defaultIndex) {
            router.replace({
                uri: "pages/home/home",
            });
        }

        if (1 == this.defaultIndex) {
            router.replace({
                uri: "pages/scene/p1",
            });
        }

        if (2 == this.defaultIndex) {
            router.replace({
                uri: "pages/message/message",
            });
        }

        if (3 == this.defaultIndex) {
            router.replace({
                uri: "pages/personal/personal",
            });
        }
    },

    switchChange(e) {
        console.log(e.checked);
        if (e.checked) {
            flag: 1;
            prompt.showToast({
                message: "打开开关",
            });
        } else {
            flag: 0;
            prompt.showToast({
                message: "关闭开关",
            });
        }
    },
};
